fn main() {
    // 条件
    let f = 0;

    if f == 1{
        println!("f is 1;");
    }
    else if f == 2 {
        println!("f is 2;");
    }
    else {
        println!("f is {};",f);
    }

    let continues = true;

    let number = if continues {
        5
    } else {
        6
    };
    // 不要加;

    println!("number is {}",number);

    // 循环
    let mut array:[i32;5] = [1,2,3,4,5];

    println!("loop-----------------");

    let mut num = 0;
    loop {
        println!("array[{}] is {};",num,array[num]);

        num += 1;

        if num >= 5 {
            break;
        }
    }

    println!("while-----------------");

    let mut num = 0;
    while num < 5 {
        println!("array[{}] is {};",num,array[num]);

        num += 1;
    }

    println!("for &arr-----------------");
    for item in &array {
        println!("array has {};",item);
    }

    println!("for iter()-----------------");
    for item in array.iter() {
        println!("array has {};",item);
    }

    // for 带有index方法

    for (index,item) in array.iter().enumerate() {
        println!("array[{}] is {};",index,item);
    }

    // for mut 
    let mut array:[i32;5] = [1,2,3,4,5];

    for mut item in &array {
        item = &0 ;
    }

    for item in array.iter_mut() {
        *item = 0;
    }

    println!("Hello, world!");
}
